<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>03routervaluetransfer</title>
    <script type="text/javascript" src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/vue-router.js"></script>
    <style>
        ul{
            list-style-type: none;
        }
        ul>li{
            float: left;
            margin-right: 20px;
        }
        ul>li a{
            text-decoration: none;
            color: rgb(250, 8, 8);
        }
        .show1{
            clear: both;
            margin-left: 40px;
            border: 1px dotted blue;
            width: 500px;
            height: 400px;
        }
        .show2{
            clear: both;
            width: 400px;
            height: 300px;
            background-color: chartreuse;
        }
    </style>
</head>
<body>
    <div id="app">
        <ul>
            <li><router-link to="/home">首页</router-link></li>
            <li><router-link to="/news">新闻</router-link></li>
            <li><router-link to="/hot">热点</router-link></li>
        </ul>
        <div class="show1">
            <router-view></router-view>
        </div>
    </div>
    <template id="hometpl">
        <div>
            <h1>首页内容</h1>
        </div>
    </template>
    <template id="newstpl">
        <div>
            <h1>新闻内容</h1>
        </div>
    </template>
    <template id="hottpl">
        <div>
            <ul>
                <li><router-link to="/hot/java">java</router-link></li>
                <li><router-link to="/hot/python">python</router-link></li>
                <li><router-link to="/hot/web">web</router-link></li>
            </ul>
            <div class="show2">
                <router-view></router-view>
            </div>
        </div>
    </template>
    <template id="javatpl">
        <div>
            <ul>
                <li><router-link to="/hot/1">spring</router-link></li>
                <li><router-link to="/hot/2">springmvc</router-link></li>
                <li><router-link to="/hot/3">springcloud</router-link></li>
            </ul>
        </div>
    </template>
    <template id="pythonpl">
        <div>
            <h5>爬虫</h5>
            <h5>数据分析</h5>
        </div>
    </template>
    <template id="webtpl">
        <div>
            <h5>layui</h5>
            <h5>css</h5>
        </div>
    </template>
    <template id="hotDetail">
        <div>
            <h2>热点详情页</h2>
            <p>
                {{$route.params.id}}
            </p>
        </div>
    </template>
</body>
</html>
<script>
    var vm=new Vue({
        el:'#app',
        router:new VueRouter({
            routes:[
                {
                    path:'/home',
                    component:{
                        template:'#hometpl'
                    }
                },
                {
                    path:'/news',
                    component:{
                        template:'#newstpl'
                    }
                },
                {
                    path:'/hot',
                    component:{
                        template:'#hottpl'
                    },
                    children:[
                        {
                            path:'java',
                            component:{
                                template:'#javatpl'
                            }
                        },
                        {
                            path:'python',
                            component:{
                                template:'#pythonpl'
                            }
                        },
                        {
                            path:'web',
                            component:{
                                template:'#webtpl'
                            }
                        }
                    ]
                },
                {
                    path:'/hot/:id',
                    component:{
                        template:'#hotDetail',
                    }
                }
            ]
        })
    });
</script>